package cn.com.elite;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServlet;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;



public class mailservlet extends HttpServlet{
	private static final Log log=LogFactory.getLog(mailservlet.class);
	private mailrun mailrun; 
	private Thread t; 
	public void destroy() {
		
	}
	public void init(){
        ServletContext application;   
        WebApplicationContext wac;   
        application=getServletContext();   
        wac=WebApplicationContextUtils.getWebApplicationContext(application);//获取spring的context  
        cn.com.elite.MailBean mailbean=(cn.com.elite.MailBean)wac.getBean("mailbean");  
	    mailrun=new mailrun();
	    mailrun.setMailbean(mailbean);
	    mailrun.setAddress(this.getInitParameter("address"));
	    mailrun.setSMTPHost(this.getInitParameter("SMTPHost"));
	    mailrun.setUsername(this.getInitParameter("username"));
	    mailrun.setPassword(this.getInitParameter("password"));
	    mailrun.setMail_sql(this.getInitParameter("mailsql"));
	    mailrun.setEml_path(this.getInitParameter("eml_path"));
	    mailrun.setF_path(this.getInitParameter("f_path"));
	    mailrun.setDotime(this.getInitParameter("dotime"));
	    
	    mailrun.setRequestType1(this.getInitParameter("requestType1"));
	    mailrun.setRequestType2(this.getInitParameter("requestType2"));
	    mailrun.setUrl(this.getInitParameter("url"));
	    mailrun.setUser(this.getInitParameter("user"));
	    mailrun.setPassword1(this.getInitParameter("password1"));
	    mailrun.setUsercode(this.getInitParameter("usercode"));
	    mailrun.setComcode(this.getInitParameter("comcode"));
	    mailrun.setSystemcode(this.getInitParameter("systemcode"));
	    log.info("servlrt_systemcode:"+this.getInitParameter("systemcode"));
	    t = new Thread(mailrun); 
		t.start();
	}
}
